<!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
		<style>
			
		</style>
		<script>
			

			/*
				遍历数组
					1. 下标
					2. 下标对应的值

				forEach()
				map()
				filter()
				every
				some
			*/

			var arr = [1,2,3,4,5];

			// 过滤出来小于3的

			/*var newArr = [];
			for( var i = 0; i < arr.length; i++ ){
				if(arr[i] < 3) newArr.push(arr[i])
			}*/

		// 返回的数组中存放的是，回调函数返回为true的那一项
		let newArr = arr.filter(function (item,index){
			console.log(item,index);
			return item < 3;	
		})

		console.log(newArr);


		</script>
	</head>

	<body>
		
	</body>
</html>